package de.tum.in.eist.im.client;

import com.google.gwt.user.client.ui.RootPanel;

import de.tum.in.eist.im.client.GUIwidgets.LoginDialog;
import de.tum.in.eist.im.client.GUIwidgets.Menu;
import de.tum.in.eist.im.client.GUIwidgets.UserOnline;

public class GUI {

	private RootPanel rootPanel = RootPanel.get("content");
	private EIST_IM parentIM;

	private LoginDialog loginDialog;

	private Menu menu;
	private Controller controller;
	private UserOnline userOnline;

	public GUI(final EIST_IM parent) {
		parentIM = parent;

		loginDialog = new LoginDialog(this);
		
		flipToLoginDialog();
	}
	
	public void flipToLoginDialog() {
		// to be up to date, always create a new "chat environment" before logging in
		menu = new Menu(this);
		controller = new Controller(this);
		userOnline = new UserOnline(this);	
		
		loginDialog.showDialog();
		menu.hide();
		controller.flipToBlank();
		userOnline.hide();
	}
	
	public void flipToChatEnvironment() {
		loginDialog.hideDialog();
		menu.show();
		controller.flipToChat();
		userOnline.show();
	}

	public Menu getMenu() {
		return menu;
	}

	public UserOnline getUserOnline() {
		return userOnline;
	}

	public LoginDialog getLoginDialog() {
		return loginDialog;
	}
	
	public EIST_IM getParentIM() {
		return parentIM;
	}

	public RootPanel getRootPanel() {
		return rootPanel;
	}
	
	public Controller getController() {
		return controller;
	}
}
